// 单例
class LoginForm {
    constructor() {}
    login() {
        console.log('login...')
    }
}

LoginForm.getInstance = (function() {
    let instance
    return function() {
        if(!instance) {
            instance = new LoginForm()
        }
        return instance
    }
})()

let login1 = LoginForm.getInstance()
console.log(login1)
let login2 = LoginForm.getInstance()
login1.login()
login2.login()
console.log('login1 === login2', login1 === login2)